import { Component, Inject } from '@angular/core';
import { IonicPage, NavController } from 'ionic-angular';

import { Subscription } from 'rxjs/Subscription';
/**
 * 更多信息(社交账号)
 */
@IonicPage()
@Component({
  selector: 'page-mine-more',
  templateUrl: 'mine-more.html'
})
export class MineMorePage{

  // 更多信息
  private moreInfo: any;
  // 监听 用户信息
  private userSubscription: Subscription;
  constructor(
    @Inject('user') private userService,
    private navCtrl: NavController,
  )
  {
    this.userSubscription= this.userService.getUser()
      .filter(user=> user.userId)
      .subscribe(user => {
        debugger;
        this.moreInfo= user.moreInfo
      })
  }

  /*** 页面离开
   * */
  ionViewWillLeave()
  {
    debugger;
    if(typeof this.userSubscription !== 'undefined')
      this.userSubscription.unsubscribe();
  }

  /*** 保存验证
   * */
  executeSave(){
    this.userService.updateMoreInfo(this.moreInfo,this.navCtrl);
  }


}

